class Solution {
    public int minimumLengthEncoding(String[] words) {
        if(words.length == 0) {
            return 1;
        }
        if(words.length == 1) {
            return words[0].length()+1;
        }
        Set<String> good = new HashSet<String>(Arrays.asList(words));
        for(String word : words) {
            for(int i = 1;i < word.length();i++) {
                good.remove(word.substring(i));
            }
        }
        int ent = 0;
        for(String word:good) {
            ent += word.length() + 1;
        }
        return ent;
    }
}